home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ASME's Mechanical Engine…ing Toolkit 1997 December
/
ASME's Mechanical Engineering Toolkit 1997 December.iso
/
fortran
/
for77win.lzh
/
DEMO.FOR
< prev
next >
Wrap
Text File
|
1987-11-15
|
7KB
|
309 lines
character*1 i1
c
c initiate window routines
c
call winit(2,imode)
c
c hide cursor
c
call hidcur
c
c make window
c
call mkwind(1,1,21,6,#1e,1,#1f)
c
c move window diagonaly from top left to bottom right
c
do 10 i=2,20
ii=i*3
call movwin(ii,i)
call sound(100,1)
call wait
10 continue
c
c move window horizontally to the left bottom corner
c
do 30 i=58,1,-3
call movwin(i,20)
call sound(100,1)
call wait
30 continue
c
c move window diagonally to top right corner
c
do 20 i=2,20
ii=i*3
jj=21-i
call movwin(ii,jj)
call sound(100,1)
call wait
20 continue
c
c move window horizontally to its original position
c
do 40 i=58,1,-3
call movwin(i,1)
call sound(100,1)
call wait
40 continue
call waitl
c
c now close window
c
call clwind
c
c gradually clear screen
c
do 50 i=1,20
j=20+i*3
k=5+i
call wincls(1,1,j,k,#57)
call wait
50 continue
call waitl
call sound(200,5)
c
c open a new window
c
call mkwind(20,8,40,11,#1f,1,#1e)
c
c display the following Welcom message
c
call wprnst(16,3,'WELCOME',7,29+128)
call wprnst(18,5,'T O',3,0)
call wprnst(10,7,'WINDOWS FOR FORTRAN',19,27)
call waitl
call wprnst(7,9,'Press any key to Continue',25,#17)
c
c wait for a key
c
call getkey(i1,i2)
c
c close window
c
call clwind
c
c make a new window and display more info.
c
call mkwind(5,2,72,21,#31,2,#3f)
call wprnst(7,2,'This Demo Will find the root of the equation',
*44,0)
call wprnst(25,3,'F(X)=COS(X)-X=0',15,59)
call wprnst(7,4,'It asks you to enter two values',21,0)
call wprnst(28,5,'X1 and X2',9,59)
call wprnst(7,6,'such that',9,0)
call wprnst(27,7,'F(X1) < 0.0',11,59)
call wprnst(27,8,'F(X2) > 0.0',11,59)
call wprnst(7,9,'or vice versa',13,0)
call wprnst(7,10,'It will iterativly calculate the root and you wi
*ll be able',58,0)
call wprnst(7,11,'to WATCH the computer doing his work.',37,0)
call wprnst(7,13,'Notice that this set of library routines does as
*sume that',57,62)
call wprnst(7,14,'humans make mistakes so it will not terminate if
* you make',57,62)
call wprnst(7,15,'one while you enter these value',31,62)
call wprnst(7,16,'EXPERIMENT this feature and',27,62)
call wprnst(23,18,'HAPPY COMPUTING....',19,63)
call wprnst(23,20,'Press any key to Continue',25,#37)
c
c wait for a key to continue
c
call getkey(i1,i2)
c
c gradually scroll window up
c
do 123 iii=1,19
call wscrup(1)
call wait
123 continue
call getkey(i1,i2)
c
c close window
c
call clwind
c
c clear screen with blue back ground
c
call cls(#17)
c
c call demo subroutine
c
call demo
c
c clear screen then exit
c
call cls(07)
c
c show cursor
c
call shwcur
end
subroutine demo
character*1 txt*80,i1
data error /1.e-6/
c
c peeb
c
call sound(300,5)
c
c make display window
c
call mkwind(20,6,40,14,75,2,67)
c
c print title and info
c
call wprnst(17,1,'DEMO',4,128+75)
call wprnst(10,2,'ROOT CALCULATION OF',19,0)
call wprnst(13,3,'F(X)=COS(X)-X',13,79)
call wprnst(5,6,'X1=',3,0)
call wprnst(5,8,'X2=',3,0)
call wprnst(21,6,'F(X1)=',6,0)
call wprnst(21,8,'F(X2)=',6,0)
c
c show cursor to aide in entering data
c
call shwcur
c
c read a real variable x1 then x2
c
22 call wreadr(10,6,x1,10,52)
call wreadr(10,8,x2,10,52)
c
c calculate cos(x1) & cos(x2)
y11=cos(x1)
y1=y11-x1
y22=cos(x2)
y2=y22-x2
y=y1*y2
c
c if x1 & x2 does not satisfy the requirements display error message
c and prompt for new values
c
if(y.gt.0) then
call sound(40,10)
call mkwind(10,10,60,6,113,2,0)
call wprnst(27,1,'ERROR',5,0)
call wprnst(19,2,'DATA IS NOT ACCEPTABLE',22,0)
call wprnst(26,3,'TRY AGAIN',9,0)
call wprnst(23,5,'Press any key',13,123)
call getkey(i1,i2)
call clwind
goto 22
endif
c
c hid cursor again
c
call hidcur
c
c else continue
c
55 x=(x1+x2)/2.
yy=cos(x)
y=yy-x
y3=y1*y
if(y3.le.0) then
x2=x
y22=yy
y2=y
else
x1=x
y1=y
y11=yy
endif
c
c use fortran write statement to generate a string to display
c
write(txt,2)x1
2 format(1x,f9.7)
call wprnstr(10,6,txt,10,52)
write(txt,2)x2
call wprnstr(10,8,txt,10,52)
write(txt,2)y1
call wprnstr(27,6,txt,10,52)
write(txt,2)y2
call wprnstr(27,8,txt,10,52)
call sound(150,1)
call waitl
c
c if y withen accepted error limit then stop calculations and display
c answer
c
if(abs(y).le.error) then
write(txt,1)x
1 format(1x,'ROOT IS ',E12.5)
call wprnst(10,10,txt,21,75)
call wprnst(13,12,'Press any key',13,0)
call getkey(i1,i2)
call clwind
return
endif
c
c else continue
c
goto 55
end
subroutine wait
c
c this subroutine does nothing it only slows down the program
c
do 10 i=1,5000
j=i
10 continue
return
end
subroutine waitl
c
c this subroutine does nothing it only slows down the program
c
do 10 i=1,30000
j=i
10 continue
return
end
subroutine wincls(i,j,id,jd,ia)
common /tareq1/n,iacces
c
c This subroutine gives you some idea of what can be done using the
c low level tools used to wite this library
c
if (iacces.eq.0) then
c
c if iacces = 0 then you use bios calls
c
i2=i+id-1
j2=j+jd-1
call bwindw(i,j,i2,j2,ia)
c
c bwindw uses the bios to fill a window with coordinates
c i,j and i2,j2 with blanks having attribute ia
c
else
c
c dwindw does the same thing except it does it by writing directly
c to display memory which result in a faster results
c
c Notice that the arguments are different now
c i,j: the upper left corner of window
c id : # of columns
c jd : # of rows
c
call dwindw(i,j,id,jd,ia)
endif
return
end